﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TKToXML.Models;
using NHibernate.Mapping.ByCode.Conformist;
using NHibernate.Mapping.ByCode;

namespace TKToXML.Persistence.ClassMaps
{
    public class HopDongChiTietMap : ClassMapping<HopDongChiTiet>
    {
        public HopDongChiTietMap()
        {
            Table("EDHOPDDONGCT");
            //ComposedId(m =>
            //{
            //    m.Property(x => x.NamChungTu, map => map.Column("Nam_CT"));
            //    m.Property(x => x.SoChungTu, map => map.Column("So_CT"));
            //    m.Property(x => x.SoThuTu, map => map.Column("So_TT"));
            //});

            Id(x => x.Id, map => map.Generator(Generators.GuidComb));

            Property(x => x.NamChungTu, map => map.Column("Nam_CT"));
            Property(x => x.SoChungTu, map => map.Column("So_CT"));
            Property(x => x.SoThuTu, map => map.Column("So_TT"));
            Property(x => x.MaHS, map => map.Column("Ma_HS"));
            Property(x => x.MaHangHoa, map => map.Column("Ma_HH"));
            Property(x => x.TenHangHoa, map => map.Column("Ten_HH"));
            Property(x => x.MaNuocXuatXu, map => map.Column("Ma_NU_XX"));
            Property(x => x.MaDonViTinh, map => map.Column("Ma_DVT"));            
            Property(x => x.SoLuong, map => map.Column("SoLuong"));
            Property(x => x.MaNguyenTe, map => map.Column("Ma_NT"));
            Property(x => x.DonGiaNguyenTe, map => map.Column("DonGia_NT"));
            Property(x => x.TriGiaNguyenTe, map => map.Column("TriGia_NT")); 
           
            //ManyToOne(x => x.HopDong, map => 
            //{   
            //    map.Columns(c => 
            //        {                       
            //            c.Name("Nam_CT");
            //            c.Name("So_CT");
            //        });
            //    map.Cascade(NHibernate.Mapping.ByCode.Cascade.All);
            //});

            ManyToOne(x => x.HopDong, map =>
                {
                    map.Column("HopDongId");
                    map.Class(typeof(HopDong));
                    map.Cascade(Cascade.All);
                });
        }
    }
}
